package com.config;


import org.springframework.amqp.core.Binding;
import org.springframework.amqp.core.BindingBuilder;
import org.springframework.amqp.core.Queue;
import org.springframework.amqp.core.TopicExchange;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class TopicMQConfig {



    @Bean
    public TopicExchange topicExchange()
    {
        return new TopicExchange("topicExchange",true,false);
    }

    @Bean
    public Queue topicQueue1()
    {
        return new Queue("topicQueue1");
    }
    @Bean
    public Queue topicQueue2()
    {
        return new Queue("topicQueue2");
    }

    @Bean
    public Binding  topicExchange_queue1()
    {
        //是com.sunjob.这里只能一级
        return BindingBuilder.bind(topicQueue1()).to(topicExchange()).with("com.sunjob.*");
    }

    @Bean
    public Binding  topicExchange_queue2()
    {
        //只要com开头就可以收到，可以是多级
        return BindingBuilder.bind(topicQueue2()).to(topicExchange()).with("com.#");
    }
}
